import { baseApi } from "./base";

export interface UserInfo {
  id: string;
  name: string;
  avatar?: string;
}

export const userApi = baseApi.injectEndpoints({
  endpoints: (build) => ({
    getUserInfo: build.query<UserInfo, void>({
      query: () => "/uapi/channel/user/status",
      providesTags: ["User"],
    }),
    updateUserInfo: build.mutation<UserInfo, Partial<UserInfo>>({
      query: (body) => ({
        url: "/uapi/user/info",
        method: "PUT",
        body,
      }),
      invalidatesTags: ["User"],
    }),
  }),
});

export const { useGetUserInfoQuery, useUpdateUserInfoMutation } = userApi;
